home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / iritsm3s.zip / CODING.STD < prev    next >
Text File  |  1990-08-11  |  3KB  |  141 lines

  1. These are the coding standards I am using. If you make some changes to the
  2. code, please attempt to follow these rules.
  3.  
  4. Gershon Elber
  5.  
  6. gershon@cs.utah.edu
  7.  
  8. ------------------------------------------------------------------------------
  9.  
  10.  
  11. GENERAL
  12. -------
  13.  
  14.     Code should not exceed column 80. If the code is going to "look"
  15.     better with more that 80 columns it is allowed but should be restricted
  16.     as possible.
  17.  
  18. NESTING
  19. -------
  20.     Nesting of all expressions is by 4 spaces. Tabs used are 8 spaces.
  21.  
  22. COMMENTS
  23. --------
  24.  
  25.     Function comments will have the following form:
  26.  
  27. /*****************************************************************************
  28. * Comment body.                                     *
  29. *****************************************************************************/
  30.  
  31.     Internal comments will be aligned to the right to column 80 if the
  32.     are commenting expression in the same line:
  33.  
  34.     i %= 2;                               /* Is i even? */
  35.  
  36.     Comments that explains the following block, will be left aligned as
  37.     the block. The comment does not need to be right aligned to column 80 as
  38.     well.
  39.  
  40. BLOCKS
  41. ------
  42.     Blocks starts with '{' and ends with '}'. If the block is beginning
  43.     of procedure then it will start with '{' at column 1 and end at column
  44.     1 with '}'. Otherwise it will start with some expression as for/if/while
  45.     etc. in the nesting form:
  46.     expression {
  47.     .
  48.     .
  49.     .
  50.     }
  51.  
  52. FOR
  53. ---
  54.     for (x = 0; x < 10; x++)
  55.  
  56.     or
  57.     for (x = 0, i = 1;
  58.          x < 5;
  59.          x++, i--)
  60.  
  61.     The body of the for loop can be in the same line where the ')' is
  62.     if it has only one expression. Otherwise the ')' will be followed by
  63.     '{' and the body will start in the next line nested 4 space deapper:
  64.  
  65.     for (....) x = sin(j);
  66.     or
  67.     for (....) {
  68.         x = y / j;
  69.         y = j + 2;
  70.     }
  71.  
  72. WHILE
  73. -----
  74.     while (x > 0) x--;        /* Use x = 0 stupid! */
  75.     or
  76.     while (x > 0 && y > 0) {
  77.         x -= 4;
  78.         y -= 4;
  79.     }
  80.     or
  81.     while (x > 0 &&
  82.            x < 5)
  83.         x /= 2;
  84.  
  85.  
  86. IF
  87. --
  88.  
  89.     if (x > 0) x = -x;
  90.     or
  91.     if (x > 0 && y > 0) {
  92.         x = -x;
  93.         y = -y;
  94.     }
  95.     or
  96.     if (x > 0)
  97.         x = -x;
  98.     else
  99.         x /= 2;
  100.     or
  101.     if (x > 0)
  102.         x = -x;
  103.     else if (x < -100)
  104.         x /= 20;
  105.     else
  106.         x /= 2;
  107.  
  108.  
  109.     Note that if the if expression has else part both bodies will be
  110.     aligned 4 space deep (The body of the if part can not be in same line
  111.     as the if and must be aligned with the else body).
  112.  
  113.  
  114. SWITCH
  115. ------
  116.  
  117.     switch (i) {
  118.         case 1:
  119.         printf("1");
  120.         break;
  121.         case 2:
  122.         printf("2");
  123.         break;
  124.         case 3:
  125.         printf("3");
  126.         break;
  127.         default:
  128.         printf("Too big");
  129.         break;
  130.     }
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.